home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / CMPLTPAS / SQUARE.PAS < prev    next >
Pascal/Delphi Source File  |  1988-07-24  |  1KB  |  33 lines

  1. {->>>>Square<<<<-----------------------------------------------}
  2. {                                                              }
  3. { Filename : SQUARE.SRC -- Last Modified 7/23/88               }
  4. {                                                              }
  5. { This routine draws a square at X,Y that is symmetrical       }
  6. { independent of the curren graphics device and mode.  The     }
  7. { Side parameter contains the measure in pixel of a side, and  }
  8. { the MeasureXAxis is a Boolean that indicates whether the     }
  9. { figure passed in Side is measured along the X Axis or the Y  }
  10. { axis.  MeasureXAxis=True assumes that Side measures along    }
  11. { X axis, and False assumes that Side measures along the Y     }
  12. { axis.                                                        }
  13. {                                                              }
  14. { The system must be in BGI graphics mode.                     }
  15. {                                                              }
  16. {     From: COMPLETE TURBO PASCAL 5.0  by Jeff Duntemann       }
  17. {    Scott, Foresman & Co., Inc. 1988   ISBN 0-673-38355-5     }
  18. {--------------------------------------------------------------}
  19.  
  20. PROCEDURE Square(X,Y,Side : Word; MeasureXAxis : Boolean);
  21.  
  22. VAR
  23.   XA,YA   : Word;
  24.   XL,YL : Word;
  25.  
  26. BEGIN
  27.   XL := Side; YL := Side;
  28.   GetAspectRatio(XA,YA);
  29.   IF MeasureXAxis THEN YL := Round((XA/YA)*Side)
  30.     ELSE XL := Round((YA/XA)*Side);
  31.   Rectangle(X,Y,X+XL,Y+YL);
  32. END;
  33.